<include file="public:header" />
<include file="public:left" />
<style>
    /* #edui1_toolbarbox{position: fixed;top: 116px;width:700px;z-index: 9999}*/
</style>
<form method="post" enctype="multipart/form-data" id="brandForm">
    <section>
        <h2><strong>关于我们</strong></h2>
        <ul class="ulColumn2">
            <li>
                <span class="item_name" style="width:120px;">标题：</span>
                <input type="text" name="title" class="textbox textbox_295" value="<if condition="isset($data.title)">{$data.title}</if>">
            </li>
            <li style="height:auto;">
                <span class="item_name" style="width:120px;">图片：</span>
                <input type="file" name="image" > <if condition="isset($data.image)"><img height="50" class="img" id="img" src="__STATIC__/uploads/{$data.image}" alt="{$data.image}"></if>
            </li>
            </li>
            <li style="height:auto;">
                <span class="item_name" style="width:120px;">内容：</span>
                <script id="editor" name="content" type="text/plain" style="width:700px;height:300px;margin-left:125px; margin-top:-12px;">{$data.content|htmlspecialchars_decode}</script>
            </li>
            <li>
                <span class="item_name" style="width:120px;"></span>
                <input type="button" class="link_btn" value="提交"/>
            </li>
        </ul>
    </section>
</form>
<div style="height: 200px"></div>

</div>
</section>
<script type="text/javascript">
    $(".link_btn").click(function(){
        var formData = new FormData();
        var title = $('input[name="title"]').val();
        var file = $('input[name="image"]')
        var image = file.get(0).files[0];
        var content = ue.getContent();
        var imagename = $("#img").attr('alt');
        formData.append('title',title);
        formData.append('image',image);
        formData.append('content',content);
        formData.append('imagename',imagename);

        $.ajax({
            url: "{:url('Set/about')}",
            type: "Post",
            data: formData,
            async: false,
            processData: false,
            contentType:false,
            success: function(result){
                if(result.code == '0'){
                    layer.alert(result.msg);
                }else{
                    layer.alert(result.msg, {
                                btn: ['确定']
                            },
                            function (index, item) {
                                location.href = result.url;
                            });
                }
            }
        });
    });
</script>
<script type="text/javascript">
//    _Ueditor = UE.getEditor('editor');

    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor');

    function isFocus(e) {
        alert(UE.getEditor('editor').isFocus());
        UE.dom.domUtils.preventDefault(e)
    }

    function setblur(e) {
        UE.getEditor('editor').blur();
        UE.dom.domUtils.preventDefault(e)
    }

    function insertHtml() {
        var value = prompt('插入html代码', '');
        UE.getEditor('editor').execCommand('insertHtml', value)
    }

    function createEditor() {
        enableBtn();
        UE.getEditor('editor');
    }
</script>
</body>
</html>